package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelOrderRoom;
import com.ktgj.hotel.service.IHotelOrderRoomService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 酒店订单房间明细Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/room")
public class HotelOrderRoomController extends BaseController
{
    @Autowired
    private IHotelOrderRoomService hotelOrderRoomService;

    /**
     * 查询酒店订单房间明细列表
     */
    @PreAuthorize(hasPermi = "hotel:room:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelOrderRoom hotelOrderRoom)
    {
        startPage();
        List<HotelOrderRoom> list = hotelOrderRoomService.selectHotelOrderRoomList(hotelOrderRoom);
        return getDataTable(list);
    }

    /**
     * 导出酒店订单房间明细列表
     */
    @PreAuthorize(hasPermi = "hotel:room:export")
    @Log(title = "酒店订单房间明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelOrderRoom hotelOrderRoom) throws IOException
    {
        List<HotelOrderRoom> list = hotelOrderRoomService.selectHotelOrderRoomList(hotelOrderRoom);
        ExcelUtil<HotelOrderRoom> util = new ExcelUtil<HotelOrderRoom>(HotelOrderRoom.class);
        util.exportExcel(response, list, "酒店订单房间明细数据");
    }

    /**
     * 获取酒店订单房间明细详细信息
     */
    @PreAuthorize(hasPermi = "hotel:room:query")
    @GetMapping(value = "/{roomid}")
    public AjaxResult getInfo(@PathVariable("roomid") Long roomid)
    {
        return AjaxResult.success(hotelOrderRoomService.selectHotelOrderRoomById(roomid));
    }

    /**
     * 新增酒店订单房间明细
     */
    @PreAuthorize(hasPermi = "hotel:room:add")
    @Log(title = "酒店订单房间明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelOrderRoom hotelOrderRoom)
    {
        return toAjax(hotelOrderRoomService.insertHotelOrderRoom(hotelOrderRoom));
    }

    /**
     * 修改酒店订单房间明细
     */
    @PreAuthorize(hasPermi = "hotel:room:edit")
    @Log(title = "酒店订单房间明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelOrderRoom hotelOrderRoom)
    {
        return toAjax(hotelOrderRoomService.updateHotelOrderRoom(hotelOrderRoom));
    }

    /**
     * 删除酒店订单房间明细
     */
    @PreAuthorize(hasPermi = "hotel:room:remove")
    @Log(title = "酒店订单房间明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomids}")
    public AjaxResult remove(@PathVariable Long[] roomids)
    {
        return toAjax(hotelOrderRoomService.deleteHotelOrderRoomByIds(roomids));
    }

//    /**
//     * 新增房型
//     * */
//    @PostMapping("/insertHotelRoom")
//    public AjaxResult insertHotelRoom(@RequestBody ){}
}
